home *** CD-ROM | disk | FTP | other *** search
- ;**************************
- ;* Window Manager *
- ;**************************
-
-
- INCLUDE Library.Txt
-
- ;-------------------------------
- ; *** External Definition ***
- ;-------------------------------
-
- XDEF InstalWindow
- XDEF DeInstalWindow
- XDEF ExecWindow
- XDEF GetWindowAuxRec
- XDEF GetWindowClip
- XDEF SetWindowClip
- XDEF SetCurrents
- XDEF GetCurrents
- XDEF WindowWithGrow
-
- ;-------------------------------
- ;**** The Window Record ****
- ;-------------------------------
-
- ;WindowRecord = Record {156 bytes}
- ;{ 0} port : GrafPort
- ;{108} windowKind : INTEGER
- ;{110} visible : BOOLEAN
- ;{111} hilited : BOOLEAN
- ;{112} goAwayFlag : BOOLEAN
- ;{113} spareFlag : BOOLEAN
- ;{114} strucRgn : RgnHandle
- ;{118} contRgn : RgnHandle
- ;{122} updateRgn : RgnHandle
- ;{126} windowDefProc : DEFfunHandle
- ;{130} dataHandle : Handle
- ;{134} titleHandle : StringHandle
- ;{138} titleWidth : INTEGER
- ;{140} ControlList : ControlHandle
- ;{144} nextWindow : WindowPeek
- ;{148} windowPic : PicHandle
- ;{152} WrefCon : LongInt
-
- ;-------------------------------
- ;** The Window AuxRecord **
- ;-------------------------------
-
- ;AuxWinRecord = Record {48}
- ;{0} Worigin : Point Origin of ClipRgn
- ;{4} WContRect : Rect Window's portRect minus scroll bars (if any)
- ;{12} WactivTxt : TEHandle Current Active TEdit
- ;{16} WactivLst : ListHandle Current Active List
- ;{20} Wgrow : Boolean True if window has grow box
- ;{22} WPrintRec : THPrint Handle to the Window Print Record
- ;{26} WindProc : ProcPtr Window Procedure
- ;{30} WvRefNum : Integer Volume RefNum.
- ;{32} WAuxRefC : LongInt the Window WrefCon
- ;{36} WText : Handle list of TEHandle
- ;{40} WList : Handle list of ListHandle
- ;{44} WPic : Handle list of Pictures
-
- ; --------------------------------
-
-
-
- ;------------------------------------------------------------------------------
- ;FUNCTION InstalWindow(VAR theWindow:WindowPtr;WindID:INTEGER;
- ; WProc:ProcPtr;hasGrow:BOOLEAN):OSErr;
- ;------------------------------------------------------------------------------
-
- ;-------------------------------
- ; Parameters
- ;-------------------------------
-
- hasGrow EQU 8
- WProc EQU 10
- WindID EQU 14
- VARtheWindow EQU 16
-
- ;-------------------------------
- ; Local Variables
- ;-------------------------------
-
- theWindow EQU -4
- theRefCon EQU -8
- theHandle EQU -12
- error EQU -14
-
- ;-------------------------------
-
- InstalWindow
- LINK A6,#-14 ;
- MOVEM.L A2-A4/D3-D7,-(SP) ;
- MOVE.W #noErr,error(A6) ;
- MOVE.L #NIL,theWindow(A6) ;
- MOVE.L #SizeWindRec,D0 ;space for
- _NewPtr ;a new window
- MOVE.W D0,error(A6) ;record.
- BNE @0 ;if error...
- MOVE.W WindID(A6),-(SP) ; exit.
- MOVE.L A0,-(SP) ;
- MOVE.L #-1,-(SP) ;
- _GetNewWindow ;get a window...
- MOVE.L (SP)+,theWindow(A6);from resource
- MOVE.W #nilHandleErr,error(A6);
- CMPI.L #NIL,theWindow(A6) ;can't read ?
- BEQ @0 ;so, exit.
- MOVEA.L theWindow(A6),A4 ;
- MOVE.L WrefCon(A4),theRefCon(A6);
- MOVE.L #NIL,WrefCon(A4) ;
- MOVE.L #SizeAuxWind,D0 ;space for
- _NewHandle ;AuxWind
- MOVE.W D0,error(A6) ;record
- BNE @1 ;error ?
- MOVEA.L theWindow(A6),A4 ;put new handle
- MOVE.L A0,WrefCon(A4) ;in WrefCon
- MOVEA.L (A0),A3 ;initialize...
- MOVE.L #0,Worigin(A3) ;
- MOVE.L portRect(A4),WContRect(A3) ;
- MOVE.L portRect+4(A4),WContRect+4(A3);
- TST.W hasgrow(A6) ;
- BEQ @2 ;if window has
- SUB.W #15,WContRect+4(A3) ;scroll bars
- SUB.W #15,WContRect+6(A3) ;portRect. -15
- @2
- MOVE.W hasgrow(A6),Wgrow(A3);
- MOVE.L #NIL,WactivTxt(A3) ;
- MOVE.L #NIL,WactivLst(A3) ;
- MOVE.L WProc(A6),WindProc(A3) ;
- MOVE.L #NIL,WPrintRec(A3) ;
- MOVE.L #0,WAuxRefC(A3) ;
- MOVE.W #0,WvRefNum(A3) ;
- MOVEQ #SizeListAuxRec,D0 ;space for
- _NewHandle ;linked list
- MOVE.W D0,error(A6) ;for list...
- BNE @1 ;
- MOVEA.L theWindow(A6),A1 ;
- MOVE.L WrefCon(A1),A1 ;initialize
- MOVE.L (A1),A3 ;fields
- MOVE.L A0,WList(A3) ;of list
- MOVEA.L (A0),A3 ;Aux record
- CLR.W LID(A3) ;
- MOVE.L #NIL,theList(A3) ;
- MOVE.L #NIL,nextList(A3) ;
- CLR.W fontList(A3) ;
- CLR.W sizList(A3) ;
- MOVE.W #SizeTEAuxRec,D0 ;and for
- _NewHandle ;text
- MOVE.W D0,error(A6) ;
- BNE @1 ;
- MOVEA.L theWindow(A6),A1 ;
- MOVE.L WrefCon(A1),A1 ;
- MOVE.L (A1),A3 ;
- MOVE.L A0,WText(A3) ;initialize
- MOVEA.L (A0),A3 ;fields
- CLR.W TID(A3) ;of text
- MOVE.L #NIL,theText(A3) ;Aux record
- MOVE.L #NIL,nextText(A3) ;
- MOVE.W #SizePicAuxRec,D0 ;
- _NewHandle ;
- MOVE.W D0,error(A6) ;and now
- BNE @1 ;for pictures.
- MOVEA.L theWindow(A6),A1 ;space for
- MOVE.L WrefCon(A1),A1 ;Pict AuxRec
- MOVE.L (A1),A3 ;
- MOVE.L A0,WPic(A3) ;
- MOVEA.L (A0),A3 ;
- CLR.W PID(A3) ;
- MOVE.L #NIL,thePic(A3) ;
- MOVE.L #NIL,nextPic(A3) ;
- CLR.L destRect(A3) ;
- CLR.L destRect+4(A3) ;
- CLR.W tMode(A3) ;
- BRA @0 ;
- @1
- MOVE.L theWindow(A6),-(SP);sorry,
- _DisposWindow ;an error occurs.
- @0
- MOVE.W error(A6),D0 ;
- MOVE.L VARtheWindow(A6),A1;
- MOVE.L theWindow(A6),(A1) ;
- MOVEM.L (SP)+,A2-A4/D3-D7 ;
- UNLK A6 ;
- MOVE.L (SP)+,A0 ;
- ADD.L #12,SP ;clean the
- MOVE.W D0,(SP) ;stack,report
- JMP (A0) ;error and quit
-
- ;------------------------------------------------------------------------------
- ;PROCEDURE ExecWindow(theEvent:EventRecord;whichWindow:WindowPtr);
- ;------------------------------------------------------------------------------
-
- ;-------------------------------
- ; Parameters
- ;-------------------------------
-
- whichWindow EQU 8
- theEvent EQU 12
-
- ;-------------------------------
-
- ExecWindow
- LINK A6,#0 ;
- MOVEM.L A2-A4/D3-D7,-(SP) ;
- MOVEA.L whichWindow(A6),A4 ;
- TST.L WrefCon(A4) ;NIL in
- BEQ @0 ;the Wind
- MOVEA.L WrefCon(A4),A2 ;Aux Record?
- MOVEA.L (A2),A2 ;
- MOVEA.L WindProc(A2),A2 ;get the Wind
- CMPA.L #NIL,A2 ;proc address
- BEQ @0 ;address is NIL?
- MOVE.L theEvent(A6),-(SP) ;push eventRec
- MOVE.L whichWindow(A6),-(SP);
- JSR (A2) ;run the WindProc
- @0
- MOVEM.L (SP)+,A2-A4/D3-D7 ;
- UNLK A6 ;
- MOVEA.L (SP)+,A0 ;
- ADD.L #8,SP ;
- JMP (A0) ;
-
- ;------------------------------------------------------------------------------
- ;FUNCTION GetWindowAuxRec(whichWindow:WindowPtr):Handle;
- ;------------------------------------------------------------------------------
-
- GetWindowAuxRec
- MOVEA.L (SP)+,A0 ;
- MOVEA.L (SP)+,A1 ;
- TST.L WrefCon(A1) ;
- BEQ @0 ;
- MOVE.L WrefCon(A1),(SP) ;
- @0
- JMP(A0) ;
-
-
-
- ;------------------------------------------------------------------------------
- ;PROCEDURE GetWindowClip(VAR contentRect:rect;VAR clipOrigin:Point;
- ; whichWindow:WindowPtr);
- ;------------------------------------------------------------------------------
-
- ;-------------------------------
- ; Parameters
- ;-------------------------------
-
- clipOrigin EQU 12
- contentRect EQU 16
-
- ;-------------------------------
-
- GetWindowClip
- LINK A6,#-0 ;
- MOVEM.L A2-A4/D3-D7,-(SP) ;
- MOVE.L whichWindow(A6),A4 ;
- TST.L WrefCon(A4) ;
- BEQ @0 ;
- MOVEA.L WrefCon(A4),A0 ;
- MOVEA.L (A0),A0 ;
- MOVEA.L clipOrigin(A6),A1 ;
- MOVEA.L contentRect(A6),A2 ;
- MOVE.L Worigin(A0),(A1) ;
- MOVE.L WContRect(A0),(A2)+ ;
- MOVE.L WContRect+4(A0),(A2) ;
- @0
- MOVEM.L (SP)+,A2-A4/D3-D7 ;
- UNLK A6 ;
- MOVEA.L (SP)+,A0 ;
- ADD.L #12,SP ;
- JMP (A0) ;
-
- ;------------------------------------------------------------------------------
- ;PROCEDURE SetWindowClip(contentRect:rect;clipOrigin:Point;
- ; whichWindow:WindowPtr);
- ;------------------------------------------------------------------------------
-
- SetWindowClip
- LINK A6,#-0 ;
- MOVEM.L A2-A4/D3-D7,-(SP) ;
- MOVE.L whichWindow(A6),A4 ;
- TST.L WrefCon(A4) ;
- BEQ @0 ;
- MOVEA.L WrefCon(A4),A0 ;
- MOVEA.L (A0),A0 ;
- MOVE.L clipOrigin(A6),Worigin(A0);
- MOVEA.L contentRect(A6),A2 ;
- MOVE.L (A2)+,WContRect(A0) ;
- MOVE.L (A2),WContRect+4(A0) ;
- @0
- MOVEM.L (SP)+,A2-A4/D3-D7 ;
- UNLK A6 ;
- MOVEA.L (SP)+,A0 ;
- ADD.L #12,SP ;
- JMP (A0) ;
-
- ;------------------------------------------------------------------------------
- ;PROCEDURE SetCurrents(currentText:TEHandle;currentList:ListHandle;
- ; whichWindow:WindowPtr);
- ;------------------------------------------------------------------------------
-
- SetCurrents
- MOVEA.L (SP)+,A0 ;
- MOVEA.L (SP)+,A1 ;
- TST.L WrefCon(A1) ;
- BEQ @0 ;
- MOVEA.L WrefCon(A1),A1 ;
- MOVEA.L (A1),A1 ;
- MOVE.L (SP)+,WactivLst(A1) ;
- MOVE.L (SP)+,WactivTxt(A1) ;
- @0
- JMP (A0) ;
-
- ;------------------------------------------------------------------------------
- ;PROCEDURE GetCurrents(VAR currentText:TEHandle;VAR currentList:ListHandle;
- ; whichWindow:WindowPtr);
- ;------------------------------------------------------------------------------
-
- GetCurrents
- MOVEA.L (SP)+,A0 ;
- MOVEA.L (SP)+,A1 ;
- TST.L WrefCon(A1) ;
- BEQ @0 ;
- MOVEA.L WrefCon(A1),A1 ;
- MOVEA.L (A1),A1 ;
- MOVE.L (SP)+,A2 ;
- MOVE.L WactivLst(A1),(A2);
- MOVE.L (SP)+,A2 ;
- MOVE.L WactivTxt(A1),(A2);
- @0
- JMP (A0) ;
-
- ;------------------------------------------------------------------------------
- ;FUNCTION WindowWithGrow(whichWindow:WindowPtr):BOOLEAN;
- ;------------------------------------------------------------------------------
-
- WindowWithGrow
- MOVEA.L (SP)+,A0 ;
- MOVEA.L (SP)+,A1 ;
- TST.L WrefCon(A1) ;
- BEQ @0 ;
- MOVEA.L WrefCon(A1),A1 ;
- MOVEA.L (A1),A1 ;
- MOVE.W Wgrow(A1),(SP) ;
- @0
- JMP (A0) ;
-
- ;------------------------------------------------------------------------------
- ;PROCEDURE DeInstalWindow(whichWindow:WindowPtr);
- ;------------------------------------------------------------------------------
-
- DeInstalWindow
- LINK A6,#-0 ;
- MOVEM.L A2-A4/D3-D7,-(SP) ;
- MOVE.L whichWindow(A6),A4 ;
- TST.L WrefCon(A4) ;
- BEQ @0 ;
- MOVE.L WrefCon(A4),A4 ;we lock
- MOVE.L A4,A0 ;WindAuxRec
- _HLock ; A4 will
- MOVE.L (A4),A4 ;point on it
- @2
- TST.L WText(A4) ;
- BEQ @1 ;
- MOVE.L WText(A4),A3 ;
- MOVE.L (A3),A2 ;
- MOVE.L nextText(A2),WText(A4);
- TST.L theText(A2) ;
- BEQ @6 ;dispose each
- MOVE.L theText(A2),-(SP) ;text...
- _TEDispose ;
- @6
- MOVE.L A3,A0 ;...and then
- _DisposHandle ;the TEAuxRec
- BRA @2 ;
- @1
- TST.L WList(A4) ;
- BEQ @3 ;
- MOVE.L WList(A4),A3 ;
- MOVE.L (A3),A2 ;
- MOVE.L nextList(A2),WList(A4);
- TST.L theList(A2) ;
- BEQ @7 ;dispose each
- MOVE.L theList(A2),-(SP) ;list...
- _LDispose ;
- @7
- MOVE.L A3,A0 ;
- _DisposHandle ;...and then
- BRA @1 ;the ListAuxRec
- @3
- TST.L WPic(A4) ;
- BEQ @4 ;
- MOVE.L WPic(A4),A3 ;
- MOVE.L (A3),A2 ;
- MOVE.L nextPic(A2),WPic(A4) ;
- TST.L thePic(A2) ;
- BEQ @8 ;dispose each
- MOVE.L thePic(A2),-(SP) ;picture
- _KillPicture ;
- @8
- MOVE.L A3,A0 ;
- _DisposHandle ;and the
- BRA @3 ;PicAuxRec
- @4
- TST.L WPrintRec(A4) ;
- BEQ @5 ;dispose
- MOVE.L WPrintRec(A4),A0 ;the PrintRecord
- _DisposHandle ;
- @5
- MOVE.L whichWindow(A6),A4 ;
- MOVE.L WrefCon(A4),A4 ;
- MOVE.L A4,A0 ;
- _HUnLock ;
- MOVE.L whichWindow(A6),-(SP);dispose the
- _DisposWindow ;window
- @0
- MOVEM.L (SP)+,A2-A4/D3-D7 ;
- UNLK A6 ;
- MOVEA.L (SP)+,A0 ;
- ADD.L #4,SP ;
- JMP (A0) ;
-
- END